home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE18 / CLINIC / TOPWTCHU.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-10-11  |  1.4 KB  |  63 lines

  1. unit TopWtchU;
  2.  
  3. interface
  4.  
  5. uses
  6.   WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     RadioGroup1: TRadioGroup;
  12.     Timer1: TTimer;
  13.     procedure RadioGroup1Click(Sender: TObject);
  14.     procedure Timer1Timer(Sender: TObject);
  15.   end;
  16.  
  17. var
  18.   Form1: TForm1;
  19.  
  20. implementation
  21.  
  22. {$R *.DFM}
  23.  
  24. function WatchWindow: HWnd;
  25. begin
  26.   Result := FindWindow('TWatchWindow', 'Watch List');
  27.   if Result = 0 then
  28.   begin
  29.     Form1.RadioGroup1.ItemIndex := -1;
  30.     Abort;
  31.   end;
  32. end;
  33.  
  34. procedure WatchesOnTop(DoIt: Boolean);
  35. var
  36.   Wnd: HWnd;
  37. const
  38.   Flags: array[Boolean] of Longint = (HWnd_NoTopMost, HWnd_TopMost);
  39. begin
  40.   Wnd := WatchWindow;
  41.   { Check whether watch window is currently }
  42.   { in appropriate state. If not, then change it }
  43.   if (GetWindowLong(Wnd, gwl_ExStyle) and
  44.       ws_Ex_TopMost <> 0) <> DoIt then
  45.     SetWindowPos(Wnd, Flags[DoIt], 0, 0, 0, 0,
  46.       swp_NoMove or swp_NoSize or swp_NoActivate);
  47. end;
  48.  
  49. procedure TForm1.RadioGroup1Click(Sender: TObject);
  50. begin
  51.   Timer1.Enabled := True
  52. end;
  53.  
  54. procedure TForm1.Timer1Timer(Sender: TObject);
  55. begin
  56.   { The timer is required because Delphi changes topmost }
  57.   { windows to non-topmost windows when apps are }
  58.   { launched and then back to topmost when they stop }
  59.   WatchesOnTop(RadioGroup1.ItemIndex = 1);
  60. end;
  61.  
  62. end.
  63.